#!/usr/bin/env bash

help(){
    cat<<__EOF__
Usage: m update [OPTION]

Description: Manage software updates on MacOS.

Options:
  --help             Show this help message
  --list             List available updates
  --install NAME     Install specific update by name
  --install-all      Install all available updates
__EOF__
}

sw_update(){
    sudo softwareupdate $@
}

option="${1}"
shift
case ${option} in
    --help)
        help
        ;;
    --list)
        sw_update --list
        ;;
    --install)
        sw_update --install "$@"
        ;;
    --install-all)
        sw_update --install --all
        ;;
    *)
        help
        ;;
esac
